/**
 * @Author: 焦质晔
 * @Date: 2019/6/20
 * @Last Modified by: mikey.zhaopeng
 * @Last Modified time: 2019-09-03 16:33:41
 */
import axios from '@/api/fetch';
import * as types from './types';
import SERVER from '@/api/server';

// 查询优秀案例征集列表信息
export const getCaseCollectionList = _params => axios.get(`${SERVER.CMSCLOUD_MARKET}/caseCollection/caseList`, { params: _params, menuId: '-1' });
// export const getCaseCollectionList = params => axios.get(`${SERVER.CMSCLOUD_MARKET}/caseCollection/caseList`, { params });

//新增优秀案例征集
export const addCaseCollect = params => axios.post(`${SERVER.CMSCLOUD_MARKET}/caseCollection/caseSave`, params);

//编辑优秀案例征集
export const updateCaseCollect = (params, id) => axios.put(`${SERVER.CMSCLOUD_MARKET}/caseCollection/caseUpdate/${id}`, params);

//新增优秀案例提报
export const addOutStandingCase = params => axios.post(`${SERVER.CMSCLOUD_MARKET}/caseManager/outstandingCase/OutStandingCaseSave`, params);

//编辑优秀案例提报
export const updateOutStandingCase = (params, id) => axios.put(`${SERVER.CMSCLOUD_MARKET}/caseManager/outstandingCase/updateById/${id}`, params);

//优秀案例评选
export const update = (params, id) => axios.put(`${SERVER.CMSCLOUD_MARKET}/caseManager/outstandingCase/update/${id}`, params);

//优秀案例查询
// export const getOutStandingList = params => axios.get(`${SERVER.CMSCLOUD_MARKET}/caseManager/outstandingCase/OutStandingCaseList`, { params });
export const getOutStandingList = _params => axios.get(`${SERVER.CMSCLOUD_MARKET}/caseManager/outstandingCase/OutStandingCaseList`, { params: _params, menuId: '-1' });

// 案例征集导出
// export const getExcelList = params => axios.post(`${SERVER.CMSCLOUD_MARKET}/caseCollection/export/excel`, params, { responseType: 'arraybuffer' });
// export const getExcelList = params => axios.post(`${SERVER.CMSCLOUD_MARKET}/caseCollection/export/excel`, params, { menuId: '-1' }, { responseType: 'arraybuffer' });
export const getExcelList = params => {
  params = Object.assign(params, { menuId: '-1' });
  return axios({
    url: `${SERVER.CMSCLOUD_MARKET}/caseCollection/export/excel`,
    method: 'get',
    params: params,
    responseType: 'blob'
  });
};

//获取案例征集附件
export const selectListByBill = params => axios.get(`${SERVER.CMSCLOUD_MARKET}/caseCollection/getListByBill`, { params });

//获取活动附件
export const selectALListByBill = params => axios.get(`${SERVER.CMSCLOUD_MARKET}/caseCollection/getALListByBill`, { params });

//根据优秀案例ID获取历史审核记录
export const getCaseReviewLogList = params => axios.get(`${SERVER.CMSCLOUD_MARKET}/caseManager/caseReviewLog/getCaseReviewLogList`, { params });

//获取活动计划列表
export const getProjectPlan = params => axios.get(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectPlan/getProjectPlan/oem1`, { params });

//优秀案例导出
// export const getOutCaseExcelList = params => axios.post(`${SERVER.CMSCLOUD_MARKET}/caseManager/outstandingCase/export/excel`, params, { responseType: 'arraybuffer' });
export const getOutCaseExcelList = params => {
  params = Object.assign(params, { menuId: '-1' });
  return axios({
    url: `${SERVER.CMSCLOUD_MARKET}/caseManager/outstandingCase/export/excel`,
    method: 'get',
    params: params,
    responseType: 'blob'
  });
};

//优秀案例评选保存日志
export const saveLog = params => axios.post(`${SERVER.CMSCLOUD_MARKET}/caseManager/caseReviewLog/saveLog`, params);

//根据planId查询活动总结详情
export const getPlanById = id => axios.get(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectPlan/${id}`);
